package com.tmt.im.service.interfaces;

import com.alibaba.fastjson2.JSONObject;
import com.tmt.im.common.enums.ChatSessionType;
import com.tmt.im.service.controller.vo.*;
import com.tmt.im.common.vo.NewChatSessionVo;
import com.tmt.im.common.vo.QueryMembersRequest;
import com.tmt.springboot.chain._DynamicInterface;
import com.tmt.springboot.common.restful.IExecuteResult;
import org.springframework.util.MultiValueMap;

import java.util.List;
import java.util.Map;

/**
 * 云信平台群组会话接口
 *
 * @Description TODO
 * @Author wuyi
 * @Date 2024/8/28 10:53
 * @Version 1.0
 **/
@_DynamicInterface
public interface IYunXinInterface {

    /**
     * 创建聊天群组
     *
     * @param creatorId
     * @param creatorNick
     * @param sessionVo
     * @param error
     * @return
     */
    JSONObject createSession(Long creatorId, String creatorNick, NewChatSessionVo sessionVo, StringBuilder error);

    JSONObject getSessionDetail(Long tid, StringBuilder error);

    /**
     * 获取当前用户加入的所有聊天群组。
     *
     * @param creatorId
     * @param error
     * @return
     */
    JSONObject getAllInSession(Long creatorId, StringBuilder error);

    /**
     * 更新群组信息
     *
     * @param operatorId
     * @param type
     * @param error
     * @return
     */
    JSONObject updateSession(Long operatorId, ChatSessionType type, UpdateSessionRequest request, StringBuilder error);

    /**
     * 解散指定群组
     *
     * @param operatorId
     * @param type
     * @param tid
     * @param error
     * @return
     */
    boolean deleteSession(Long operatorId, ChatSessionType type, Long tid, StringBuilder error);

    /**
     * 群组禁言
     * @param operatorId
     * @param type
     * @param tid
     * @param bannedType
     * @param error
     * @return
     */
    boolean bannedSession(Long operatorId, ChatSessionType type, Long tid, int bannedType, StringBuilder error);

    /**
     * 更新群组的JoinMode参数
     * @param tid
     * @param ownerId
     * @param joinMode 0，不用验证；1，需要群主或管理员的验证；
     * @param error
     * @return
     */
    boolean updateSessionJoinMode(Long tid, Long ownerId, int joinMode, StringBuilder error);

    /**
     * 转让群主
     *
     * @param operatorId
     * @param tid
     * @param type
     * @param newOwnerId 新群主的ID
     * @param leave      原群主是否退出该群组?
     * @param error
     * @return
     */
    boolean transferSession(Long operatorId, Long tid, ChatSessionType type, Long newOwnerId, boolean leave, StringBuilder error);

    /**
     * 添加管理员
     *
     * @param operatorId
     * @param tid
     * @param type
     * @param managers
     * @param error
     * @return
     */
    boolean addManager(Long operatorId, Long tid, ChatSessionType type, List<Long> managers, StringBuilder error);

    /**
     * 移除管理员
     *
     * @param operatorId
     * @param tid
     * @param type
     * @param managers
     * @param error
     * @return
     */
    boolean removeManager(Long operatorId, Long tid, ChatSessionType type, List<Long> managers, StringBuilder error);

    /**
     * 分页获取群组的成员列表。
     *
     * @param operatorId
     * @param tid
     * @param type
     * @param request
     * @param error
     * @return
     */
    JSONObject queryMembers(Long operatorId, Long tid, ChatSessionType type, QueryMembersRequest request, StringBuilder error);

    /**
     * 来人入群
     *
     * @param operatorId
     * @param tid
     * @param type
     * @param beInvitedMode
     * @param inviteMsg
     * @param memberIds
     * @param error
     * @return
     */
    JSONObject joinSession(Long operatorId, Long tid, ChatSessionType type, int beInvitedMode,
                           String inviteMsg, List<Long> memberIds, StringBuilder error);

    /**
     * 踢人出群
     *
     * @param operatorId
     * @param tid
     * @param type
     * @param memberIds
     * @param error
     * @return
     */
    JSONObject kickOutSession(Long operatorId, Long tid, ChatSessionType type, List<Long> memberIds, StringBuilder error);

    /**
     * 主动退群
     *
     * @param operatorId
     * @param tid
     * @param type
     * @param error
     * @return
     */
    boolean leaveSession(Long operatorId, Long tid, ChatSessionType type, StringBuilder error);

    /**
     * 更新用户群昵称
     * @param currentUserId
     * @param tid
     * @param type
     * @param request
     * @param error
     * @return
     */
    boolean updateMemberNick(Long currentUserId, Long tid, ChatSessionType type,
                                             UpdateMemberNickRequest request, StringBuilder error);
    /**
     * 群成员禁言
     *
     * @param currentUserId
     * @param tid
     * @param type
     * @param request
     * @param error
     * @return
     */
    JSONObject bannedMembers(Long currentUserId, Long tid, ChatSessionType type, ChatBannedRequest request, StringBuilder error);

    /**
     * 群消息免打扰。
     * @param currentUserId
     * @param tid
     * @param type
     * @param request
     * @param error
     * @return
     */
    boolean noDisturbingMember(Long currentUserId, Long tid, ChatSessionType type, NoDisturbingRequest request, StringBuilder error);

    /**
     * 发送自定义系统通知
     *
     * @param senderId
     * @param type
     * @param receiverId
     * @param content
     * @param sound
     * @param notification_config
     * @param push_config
     * @return
     */
    boolean sendCustomizedMessage(Long senderId, int type, Long receiverId,
                                  String content, String sound,
                                  Map<String, Object> notification_config,
                                  Map<String, Object> push_config,
                                  StringBuilder error);

    /**
     * 批量发送自定义系统通知
     *
     * @param senderId
     * @param receiverIds
     * @param content
     * @param sound
     * @param notification_config
     * @param push_config
     * @return
     */
    boolean sendCustomizedMessages(Long senderId, List<Long> receiverIds,
                                   String content, String sound,
                                   Map<String, Object> notification_config,
                                   Map<String, Object> push_config,
                                   StringBuilder error);
}
